package com.android.infantschool.ui.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.infantschool.R;
import com.android.infantschool.bean.HiddenManagerBean;
import com.bumptech.glide.Glide;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author Administrator
 * @particulars
 * @time 2019\6\20 0020 15:32
 * @class describe
 */
public class HiddenDetailsActivity extends BaseActivity {

    @BindView(R.id.img_back)
    public ImageView imgBack;
    @BindView(R.id.tv_title)
    public TextView tvTitle;
    @BindView(R.id.title)
    public RelativeLayout rlTitle;
    @BindView(R.id.tv_hidden_name)
    public TextView tvHiddenName;
    @BindView(R.id.tv_time_and_name)
    public TextView tvTimeAndName;
    @BindView(R.id.img_details_1)
    public ImageView imgDetails1;
    @BindView(R.id.img_details_2)
    public ImageView imgDetails2;
    @BindView(R.id.img_details_3)
    public ImageView imgDetails3;

    private HiddenManagerBean.DataBean bean;

    public static Intent newIntent(Activity activity, HiddenManagerBean.DataBean bean) {
        Intent intent = new Intent(activity, HiddenDetailsActivity.class);
        intent.putExtra("data", bean);
        return intent;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hidden_details);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        bean = (HiddenManagerBean.DataBean) getIntent().getSerializableExtra("data");
        rlTitle.setPadding(0, this.height, 0, 0);
        tvTitle.setText("隐患详情");
        tvHiddenName.setText(bean.getTitle());
        tvTimeAndName.setText(bean.getAdd_time() + "\t" + bean.getName());

        if (bean.getUrl() != null) {
            if (bean.getUrl().size() > 0) {
                if (bean.getUrl().size() == 1) {
                    imgDetails1.setVisibility(View.VISIBLE);
                    Glide.with(this).load(bean.getUrl().get(0)).into(imgDetails1);
                }
                if (bean.getUrl().size() == 2) {
                    imgDetails1.setVisibility(View.VISIBLE);
                    imgDetails2.setVisibility(View.VISIBLE);
                    Glide.with(this).load(bean.getUrl().get(0)).into(imgDetails1);
                    Glide.with(this).load(bean.getUrl().get(1)).into(imgDetails2);
                }
                if (bean.getUrl().size() == 3) {
                    imgDetails1.setVisibility(View.VISIBLE);
                    imgDetails2.setVisibility(View.VISIBLE);
                    imgDetails3.setVisibility(View.VISIBLE);
                    Glide.with(this).load(bean.getUrl().get(0)).into(imgDetails1);
                    Glide.with(this).load(bean.getUrl().get(1)).into(imgDetails2);
                    Glide.with(this).load(bean.getUrl().get(2)).into(imgDetails3);
                }
            }
        }
    }

    @OnClick({R.id.img_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                this.finish();
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}